package com.game.base.server.cloud;

import android.util.Log;

import cn.bmob.v3.AsyncCustomEndpoints;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.CloudCodeListener;

/**
 * 云函数
 * Created by Su on 2019/5/21.
 */
public class CloudFMgr {

    /**
     * 调用云函数
     *
     * @param funName  云函数名
     */
    public static void callEndpoint(String funName) {
        AsyncCustomEndpoints ace = new AsyncCustomEndpoints();
        //第一个参数是云函数的方法名称，第二个参数是上传到云函数的参数列表（JSONObject cloudCodeParams），第三个参数是回调类
        ace.callEndpoint(funName, new CloudCodeListener() {
            @Override
            public void done(Object o, BmobException e) {
                if (e == null) {
                    String result = o.toString();
                    Log.d("bmob_cloud_function", result);
                } else {
                    Log.d("bmob_cloud_function", " " + e.getMessage());
                }
            }
        });
    }
}
